package com.kaifamiao.thread.d0928.pm;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

public class UDPDemo {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();

        InetAddress address = InetAddress.getLocalHost();
        int port = 8888;
        DatagramPacket packet = new DatagramPacket(str.getBytes(), 0,
                str.getBytes().length, address, port);


        DatagramSocket socket = new DatagramSocket();

        socket.send(packet);

        System.out.println("UDP 发送成功");
    }
}
